package com.warren.demo.controller;

import com.warren.demo.entity.Role;
import com.warren.demo.entity.RoleUser;
import com.warren.demo.entity.User;
import com.warren.demo.entity.UserRole;
import com.warren.demo.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("/query")
    public List query() {
        List<User> list = null;
        try {
            list = this.userService.queryAll();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    @RequestMapping("/queryRole")
    public List queryRole() {
        List<Role> list = null;
        try {
            list = this.userService.queryRole();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    @RequestMapping("/queryUserRole")
    public List queryUserRole() {
        List<UserRole> list = null;
        try {
            list = this.userService.queryUserRole();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    @RequestMapping("/queryRoleUser")
    public List queryRoleUser() {
        List<RoleUser> list = null;
        try {
            list = this.userService.queryRoleUser();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}
